home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga News 95
/
Amiga News 95.iso
/
dpat
/
dpat63
/
pp_amigaguide
/
pp_amigaguide.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-06
|
4KB
|
135 lines
/*
* PP_AmigaGuide v2.0
* © LFSoft 1994
*
* Purpose: To read an AmigaGuide file crunched using PowerPacker.
*
* History:
* v?.? 30-09-1993 Seb. BOUCHEX.
* First released version ( © S.BOUCHEX )
*
* v2.0 05-03-1994 Laurent FAILLIE
* Totaly rewriten source code but ShowAmigaGuideFile().
* Add WorkBench support.
*
* This release was developped and tested on an 68010, 6Mb, Amiga 1000, under
* ks 37.210 & wb 38.35 (2.1). It was compiled w/ Dice v 2.07.54R and can be
* made resident.
*
* This software is a FreeWare product so you can use it as you want but no
* part can be added or used in Commercial product without my written
* permission (this include covers disks for magazins !). Also, permission
* is granted for inclusion in all DP libraries ( AmigaLibDisk - Fred Fish -,
* CAM, DPAF, ...
*
* No warranty is assumed by myself or S.Bouchex. Use it at your own risk !
*
* Laurent FAILLIE
* "Les Vuardes"
* 74930 Pers-Jussy
* FRANCE
*/
/* Use PP, reqtools & AmigaGuide */
// Pour éviter que <proto/reqtools.h> ne le redefinisse
#define ReqToolsBase_DECLARED
struct ReqToolsBase *ReqToolsBase = (struct ReqToolsBase *)0L;
#define U_AMIGAGUIDE
#include <LF.h> // My own include, include all header wanted for PP,RT & AG
#include <proto/dos.h>
#include <proto/exec.h>
#include <stdio.h>
#include <stdlib.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
struct Library *AmigaGuideBase=NULL;
void la_ferme( void ){
if (AmigaGuideBase) CloseLibrary(AmigaGuideBase);
if(ReqToolsBase)
CloseLibrary((struct Library *)ReqToolsBase);
}
LONG ShowAmigaGuideFile (char *nom) {
struct NewAmigaGuide nag = {NULL};
AMIGAGUIDECONTEXT handle;
LONG retval = 0L;
nag.nag_Name = nom;
if ( handle = OpenAmigaGuide(&nag,NULL))
CloseAmigaGuide(handle);
else
retval = IoErr();
return (retval);
}
void loadAGfile( char *fch){
char *buffer;
long len;
if ((AmigaGuideBase = (struct Library *)OpenLibrary ("amigaguide.library", 0L))==NULL){
puts ("can't open amigaguide.library ");
exit(25);
}
if (!ppLoadData(fch,DECR_POINTER, 0L,&buffer,&len,NULL)){
char *tmp=tmpnam(NULL);
FILE *t;
if(t=fopen(tmp,"w")){
fwrite(buffer,1,len,t);
fclose(t);
ShowAmigaGuideFile(tmp);
remove(tmp);
} else
rtEZRequest("Can't write temporary file", "OK",NULL,NULL);
FreeMem(buffer,len);
} else {
rtEZRequest("Can't read %s\n", "OK",NULL,NULL,fch);
exit(20);
}
}
void main(int ac,char **av){
puts("pp_AmigaGuide v2.0 © LF Soft 1994\n"
" idea and first version from Sebastien BOUCHEX");
if(ac != 2){
puts(" Syntaxe: pp_AmigaGuide <file.guide>");
exit(20);
}
atexit(la_ferme);
if (!(ReqToolsBase=(struct ReqToolsBase *) OpenLibrary(REQTOOLSNAME,REQTOOLSVERSION))){
LFatal("Can't open ReqTools.library V38+");
exit(20);
}
loadAGfile(av[1]);
}
void wbmain(struct WBStartup *wbarg){
atexit(la_ferme);
if (!(ReqToolsBase=(struct ReqToolsBase *) OpenLibrary(REQTOOLSNAME,REQTOOLSVERSION))){
LFatal("Can't open ReqTools.library V38+");
exit(20);
}
if(wbarg->sm_NumArgs == 1){
rtEZRequest(" pp_AmigaGuide v2.0 © LFSoft 1994\n\n"
"Display an cruncher AmigaGuide file.", "OK",NULL,NULL);
} else {
BPTR ocd=NULL;
int nbre;
for(nbre = 1;nbre < wbarg->sm_NumArgs;nbre++){
ocd = CurrentDir(wbarg->sm_ArgList[nbre].wa_Lock);
loadAGfile(wbarg->sm_ArgList[nbre].wa_Name);
CurrentDir(ocd);
}
}
}